//
//  LcApiError.h
//  18Birdies
//
//  Created by Lc on 15/3/24.
//  Copyright (c) 2015年 Lc. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum {
  LcApiErrorUserAlreadyChanged = -3,
  LcApiErrorJsonError = -2,
  LcApiErrorEncryptionError = -1,
  LcApiErrorTypeUnKnown = 0,
  LcApiError_INTERNAL,
  LcApiError_API_NOT_FOUND,
  LcApiError_NOT_AUTHORIZED,
  LcApiError_SESSION_EXPIRED,
  LcApiError_LOGINED_FROM_OTHER_CLIENT,
  LcApiError_INVALID_PARAMETER,
  LcApiError_REQUEST_FORMAT_ERROR,
  LcApiError_CLIENT_VERSION_TOO_OLD,
} LcApiErrorType;

@interface LcApiError : NSObject

@property(nonatomic, assign, readonly) LcApiErrorType reasonCode;
@property(nonatomic, copy, readonly) NSString* reason;

// for reasonCode is AppReasonCode.CLIENT_VERSION_TOO_OLD
@property(nonatomic, assign, readonly) BOOL isWholeAppNeedUpgrade;
/**
 * for reasonCode is AppReasonCode.CLIENT_VERSION_TOO_OLD
 * message of client alert dialog, may be null
 */
@property(nonatomic, copy, readonly) NSString* upgradeMessage;
/**
 * for reasonCode is AppReasonCode.CLIENT_VERSION_TOO_OLD
 * only has meaning when {@link #isWholeAppNeedUpgrade} is false
 */
@property(nonatomic, assign, readonly) BOOL needStopBackgroundTask;

+ (LcApiError*)apiErrorWithReasonCode:(LcApiErrorType)reasonCode
                               reason:(NSString*)reason;

@end
